package com.allwees.bs.c.module.ops.vo;

import com.allwees.bs.c.module.user.entity.UserCouponEntity;
import com.allwees.core.common.constant.EStatus;

/**
 * @Author Daniel
 * @Version 1.0.0
 * @Description
 * @CreateTime 2020/9/11 9:58
 */
public class UserCouponVo extends UserCouponEntity {
    private static final long serialVersionUID = -5836642622647952122L;

    public UserCouponVo(UserCouponEntity entity){
        this.setCouponName(entity.getCouponName());
        this.setOverdueTime(entity.getOverdueTime());
        int status = entity.getStatus();
        this.setStatus(status);
        if(status == EStatus.NORMAL.value()){
            long current = System.currentTimeMillis();
            if(current >= entity.getOverdueTime().getTime()){
                this.setStatus(EStatus.COUPON_EXPIRED.value());
            }
        }
        this.setUpdatedAt(entity.getUpdatedAt());
    }
}
